#include <stdbool.h>
#include <stdio.h>
#define QUEUE_SIZE 10
typedef int ElementType;

struct queue {
    int front;
    int rear;
    ElementType data[QUEUE_SIZE];
};

void init(struct queue *q) {
    q->rear = q->front = 0;
}

int isEmpty(struct queue *q) {
    return q->front == q->rear;
}

int isFull(struct queue *q) {
    return q->front == (q->rear + 1) % QUEUE_SIZE;
}

int enqueue(struct queue *q, ElementType x) {
    if (isFull(q)) {
        printf("Queue is full\n");
        return false;
    }
    q->data[q->rear] = x;
    q->rear = (q->rear + 1) % QUEUE_SIZE;
    return true;
}

int dequeue(struct queue *q, ElementType *x) {
    if (isEmpty(q)) {
        printf("Queue is empty\n");
        return false;
    }
    *x = q->data[q->front];
    q->front = (q->front + 1) % QUEUE_SIZE;
    return true;
}

void test_queue(void) {
    struct queue q;
    init(&q);
    enqueue(&q, 10);
    enqueue(&q, 20);
    enqueue(&q, 30);
    enqueue(&q, 40);
    enqueue(&q, 50);
    enqueue(&q, 60);
    enqueue(&q, 70);
    enqueue(&q, 80);
    enqueue(&q, 90);
    enqueue(&q, 100);
    enqueue(&q, 110);
    enqueue(&q, 120);
    int x;
    while (!isEmpty(&q)) {
        dequeue(&q, &x);
        printf("%2d ", x);
    }
}

int main() {
    test_queue();
    return 0;
}
